import axios from 'axios';

const prefix = process.env.NODE_ENV === 'development' ? '/api' : '';
const create_learning_record = prefix + '/knowledge/learning/save/';
const update_learning_progress = prefix + '/knowledge/learning/complete/';

export default {
  saveLearningRecord: function (parameter, callback, errorHandler) {
    axios.post(create_learning_record + parameter)
      .then(function (resp) {
        callback(resp.data.respObject);
      }).catch(function (resp) {
        errorHandler(resp);
      });
  },

  updateLearningProgress: function (parameter, callback, errorHandler) {
    axios.patch(update_learning_progress + parameter)
      .then(function (resp) {
        callback(resp.data.respObject);
      }).catch(function (resp) {
        errorHandler(resp);
      });
  }

}
